package regexInput;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * For Use with NFA and DFA
 */
public class DSTable implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3327646884595655276L;
	private ArrayList<String> charClasses;	//will start at one, these are the transition specifiers example ($DIGIT)
	private ArrayList<TableNode> states;	//will start at zero,
	
	public DSTable(){
		charClasses = new ArrayList<String>();
		states= new ArrayList<TableNode>();
		charClasses.add("");				//offset by one
	}
	
	public ArrayList<String> getCharClasses(){
		return charClasses;
	}
	
	public void addCharClasses(String charClass){
		charClasses.add(charClass);
	}
	
	public void setCharClasses(ArrayList<String> charClassList){
		charClasses = charClassList;
	}
	
	public void addState(String name, int state){
		states.add(new TableNode(name, state));
	}
	
	public void addSetState(TableNode node){
		states.add(node);
	}
	
	public TableNode getState(int index){
		return states.get(index);
	}
	
	public String toString(){
		String s= "\t\t";
		for(int i = 1; i < charClasses.size(); i++){
			s += "|\t" + charClasses.get(i) + "\t";
		}
		s+= "|\n-------------------------------------------------------------------------\n";
		for (int i = 0; i < states.size(); i++){
			s += states.get(i).toString();
		}
		s+= "\n---------------------------------------------------------------------------\n";
		return s;
	}
}
